<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title><spring:message code="message.lable.TuiHuoDan"/></title>
<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
<!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
	<input type="hidden" id="typeflag" value='null'>
	<section class="content-header">
		<h1>未确认退货单</h1>
	    <ol class="breadcrumb">
	        <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
	        <li class="active"><a href="#">交易</a></li>
	        <li class="active"><a href="#">订单管理</a></li>
	        <li class="active"><a href="#">退货单查询</a></li>
	        <li class="active"><a href="#">未确认退货单</a></li>
	    </ol>
	</section>

	<section class="content">
	<div class=" box box-success">
		<div class="box-body">
			<form class=" form-inline" id='form'>
				<div class="input">
		  		<div class="textalign1"><spring:message code="message.listForm.tongYongMing"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="drugName" name="drugName" placeholder="<spring:message code="message.listForm.tongYongMing"/>" />
                    </div>
				<div class="textalign1"><spring:message code="message.listForm.yiLiaoJiGou"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="hospName" name="hospName" placeholder="<spring:message code="message.listForm.yiLiaoJiGou"/>" />
                 </div>
               
                 <div class="textalign"><spring:message code="message.listForm.YiLiaoJiGouDiQu"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="hidden" id="myAreaId" name="areaId" />
                       <table style="width:100%">
                           <tr>
                              <td style="width:33%">
                                <select class="textinput" id="areaId" disabled="disabled">
                                	<option value="${area.areaId}">${area.areaName}</option>
                                </select>
                              </td>
                              <td style="width:33%">   
                                <select class="textinput" id="area1"></select>
                                </td>
                              <td style="width:33%">
                                <select class="textinput" id="area2"></select>
                              </td>
                           </tr> 
                        </table>     
                    </div>
             </div>
             <div class="input" style="margin-top:-5px">
                 <div class="textalign1"><spring:message code="message.listForm.PeiSongQiYe"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="delCompName" name="delCompName" placeholder="<spring:message code="message.listForm.PeiSongQiYe"/>" />
                    </div>
                 <div class="textalign1" ><spring:message code="message.listForm.TuiHuoRiQi"/><spring:message code="message.yanZheng.maoHao"/></div>
                   <div class="boxinput"> 
                        <table style="width:100%;">
                                <tr>
                                    <td style="width:50%">       
                                        <input class="textinput" type="text" name="startDate" id="startDate"
						  placeholder="yyyy-MM-dd" onFocus="var endDate=$dp.$('endDate');WdatePicker({maxDate:'#F{$dp.$D(\'endDate\')}'})"/>
						            </td> 
                                    <td>&nbsp;-&nbsp;</td>
                                    <td style="width:50%">       
                                        <input class="textinput" type="text" name="endDate" id ="endDate"
						placeholder="yyyy-MM-dd" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startDate\')}'})"/>
                                    </td>
                                </tr>
                         </table>        
                    </div>
                    <div class="textalign1" >
				          <button type="button" class="btn btn-success btn-sm" id="selectDicCompType"><spring:message code="message.button.seachSpacing"/></button>
			    	</div>
                 </div>
                 
			</form>
		</div>
	</div>
	<table class="jqgrid" id="gridlist"></table>
	<div id="gridpage"></div>
	</section>
	<%@ include file="/WEB-INF/component/commonJS.jsp"%>
	<script type="text/javascript">
	
		$(function() {
			//绑定回车   id="selectSee"
			$('#drugName,#hospName,#myAreaId','#delCompName','#startDate','#endDate').bind('keydown', function(event) {
			    if (event.keyCode == "13") {
			        $('#selectSee').click();
			    }
			}); 
			$("#drugName").focus();//加载页面光标在第一个查询框内
			var postJson = formatForm("form");
			$("#gridlist").jqGrid(
					{   url : "getProCompReturnOrderList.html",
						mtype : "POST",
						datatype : "json",
						postData:postJson,
						autowidth : true,
						shrinkToFit : false,
						height : 350,
						colNames : [ 
							 '<spring:message code="message.listForm.TuiHuoShuLiang"/>',
							 '<spring:message code="message.listForm.TuiHuoYuanYin"/>',
							 '<spring:message code="message.listForm.tongYongMing"/>', 
                             '<spring:message code="message.listForm.jiXing"/>',
                             '<spring:message code="message.listForm.guiGe"/>',
                             '<spring:message code="message.listForm.baoZhuangDanWei"/>', 
                             '<spring:message code="message.listForm.caiZhi"/>',
                             '<spring:message code="message.listForm.zhuanHuanXiShu"/>',
                             '国药准字',
				             '<spring:message code="message.listForm.yiLiaoJiGou"/>',
				             '<spring:message code="message.listForm.YiLiaoJiGouDiQu"/>',
				             '<spring:message code="message.listForm.PeiSongQiYeName"/>',
				             '<spring:message code="message.listForm.yaoPinBianMa"/>',
				             '批号',
							 '采购价',
					         '到货数量',
					         '<spring:message code="message.listForm.TuiHuoDanHao"/>',
					         '<spring:message code="message.listForm.TuiHuoShiJian"/>',
		                     '退货人'
						],
						colModel : [
                            {name : 'retCount', width : 80, sortable: false, align : "right",
                            	formatter:function(val, options, row){
                                    return "-" + val;
                                }
                            },
                            {name : 'retReason', width : 160, sortable: false, align : "left"},
                            {name : 'drugName', width : 180, sortable: false, align : "left"},
                            {name : 'formName', width : 80, sortable: false, align : "center"},
                            {name : 'specName', width : 80, sortable: false, align : "left"},
                            {name : 'unitName', width : 80, sortable: false, align : "center"}, 
                            {name : 'materialName', width : 80, sortable: false, align : "center"}, 
                            {name : 'factor', width : 80, sortable: false, align : "center"},
                            {name : 'drugMedicine', width : 80, sortable: false, align : "center"},
                            {name : 'hospName', width : 180, sortable: false, align : "left"/*,
                                formatter:function(val, options, row){
                                    return hospInfoLink(row.hospCode, val, 1);
                                }*/
                            }, 
                            {name : 'areaName', width : 120, sortable: false, align : "center"},
                            {name : 'delCompName', width : 200, sortable: false, align : "left"/*,
                                formatter:function(val, options,row) {
                                    return compInfoLink(row.delCompCode, val, 1);
                               }*/
                            },
                            {name : 'drugCode', width :100, sortable: false,hidden:true, align : "center"/*,
                                formatter:function(val, options, row) {
                                    return drugInfoLink(val);
                                }*/
                            },
                            {name : 'approveCode', width : 80, sortable: false, align : "center"},
                            {name : 'proPrice', width : 80, sortable: false, align : "right",
                                formatter:function(val, options, row){
                                    return formatAmount(val);
                                }
                            },
                            {name : 'totalAmount', width : 80, sortable: false, align : "right"},
                            {name : 'retCode', width : 180, sortable: false, align : "center"},
				            {name : 'updTime', width : 160, sortable: false, align : "center"},
							{name : 'updUser', width : 200, sortable: false, align : "left"}
						],
						rowNum : 20,
						rowList : [ 10, 20,50,100],
						rownumbers : true,
						pager : "#gridpage",
						//multiselect: true, 
						viewrecords : true,
						gridComplete: function(){
				        	 //序号列宽度自适应（参数为jqgridID）
				               autoRNWidth("gridlist");
				           	//数据只有一条时默认选中（参数为jqgridID）
				            //   selectByOneData("gridlist");
						},
						caption : "退货单明细列表",
						jsonReader : {
							repeatitems : false,
							id : "ids"
						}
					});
			$("#area1").HNSelect({
                url: "${ctx}/selectController/getArea.html", 
                data: { ID: '${sysAreaId}' }, 
                defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
                defaultselect: "",
                func: function () {
                    $("#area2").HNSelect({
                        parent_selector: "#area1", 
                        url: "${ctx}/selectController/getArea.html", 
                        dataid: "ID", 
                        defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
                        defaultselect: ""
                    });
                }
            });
			$("#gridlist").jqGrid('navGrid', '#gridpage', {add : false,edit : false,del : false,search : false,refresh : false});
			$(window).trigger("resize");
			
		   /*按条件查询*/
		   $('.btn-success').click(function(){
			    var drugCode = $.trim($("#drugCode").val());
			    var drugName = $.trim($("#drugName").val());
	            var hospName = $.trim($("#hospName").val());
	            var delCompName = $.trim($("#delCompName").val());
	            var startDate = $.trim($("#startDate").val());
	            var endDate = $.trim($("#endDate").val());
	            var areaId = $.trim($("#area2").val());
	            if (areaId == null || areaId == "") {
	            	areaId = $.trim($("#area1").val());
	            }
	            if (areaId == null || areaId == "") {
                    areaId = $.trim($("#areaId").val());
                }
	            $("#gridlist").jqGrid("clearGridData");
	                $("#gridlist").jqGrid('setGridParam',{  
	                mtype: "POST",
	                datatype:'json',
	                postData:{
	                    "drugCode":drugCode, 
	                    "drugName":drugName,
	                    "hospName":hospName,
	                    "delCompName":delCompName,
	                    "startDate":startDate,
	                    "endDate":endDate,
	                    "areaId" : areaId
	                },
	                page : 1
	            }).trigger("reloadGrid"); //重新载入  
		   });
		   
		});
	</script>
</body>
</html>